package routers

import (
	"log"

	"gitee.com/lorock/goconfig"
	"gitee.com/lorock/goconfig/example/gin/handlers"
	"github.com/fvbock/endless"
	"github.com/gin-gonic/gin"
)

// SetupRouter 配置路由信息
func SetupRouter() {
	// 配置初始化
	goconfig.Init()
	port := goconfig.GetString("APP_SERVER_PORT")
	r := gin.New()
	r.GET("/hello", handlers.Hello)
	r.GET("/ping", handlers.Ping)
	r.GET("/version", handlers.Version)
	//监听端口默认为8080
	s := endless.NewServer(":"+port, r)
	err := s.ListenAndServe()
	if err != nil {
		log.Printf("server err: %v", err)
	}
}
